import unittest
import requests
import json
import jsonpath
from common.config_utils import config

class TestGetUserTag(unittest.TestCase):
    def setUp(self) -> None:
        self.Host= config.Host
        self.seession=requests.session()
    def tearDown(self) -> None:
        self.seession.close()
    def test_get_user_tag(self):
        self._testMethodName = 'usertag01'
        self._testMethodDoc = '正常获取用户标签'
        url_param1 = {"grant_type": "client_credential",
                     "appid": "wx71ad615ece9fc889",
                     "secret": "0ea4dbdbc5237ce7fe83def223d80ff2"}
        rp1 = self.seession.get('https://%s/cgi-bin/token'%self.Host,
                              params=url_param1)
        rp1_token_j = json.loads(rp1.content.decode('utf-8'))
        token = jsonpath.jsonpath(rp1_token_j, '$.access_token')[0]

        url_param={"access_token":token}
        rp = self.seession.get('https://%s/cgi-bin/tags/get'%self.host,
                              params=url_param)
        print(rp.status_code)
        self.assertEqual(200,rp.status_code)

# if __name__=='__main__':
#     unittest.main(verbosity=2)

